home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / misc / o-z / x-windows / mesa-amiwin / src / attrib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-30  |  17.0 KB  |  542 lines

  1. /* attrib.c */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  1.2
  6.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * Attribute stack
  26.  */
  27.  
  28.  
  29. /*
  30. $Id: attrib.c,v 1.10 1995/11/01 23:18:22 brianp Exp $
  31.  
  32. $Log: attrib.c,v $
  33.  * Revision 1.10  1995/11/01  23:18:22  brianp
  34.  * update CC.Light.LastEnabled when poping GL_ENABLE_BIT
  35.  *
  36.  * Revision 1.9  1995/10/27  20:29:02  brianp
  37.  * added glPolygonOffsetEXT() support
  38.  *
  39.  * Revision 1.8  1995/08/31  21:32:45  brianp
  40.  * new TexGenEnabled bitfield
  41.  * introduced CC.NewState convention
  42.  *
  43.  * Revision 1.7  1995/07/24  18:58:55  brianp
  44.  * added CC.ClipSpans logic to glPopAttrib()
  45.  *
  46.  * Revision 1.6  1995/07/17  15:36:32  brianp
  47.  * fixed malloc size problem for stipples per Steve Freitag (stevef@ultranet.com)
  48.  * added missing code for popping GL_POLYGON_STIPPLE_BIT attribute
  49.  *
  50.  * Revision 1.5  1995/05/22  21:02:41  brianp
  51.  * Release 1.2
  52.  *
  53.  * Revision 1.4  1995/03/27  20:30:12  brianp
  54.  * new Texture.Enabled sheme
  55.  *
  56.  * Revision 1.3  1995/03/24  17:00:59  brianp
  57.  * added gl_update_pixel_logic
  58.  *
  59.  * Revision 1.2  1995/03/04  19:29:44  brianp
  60.  * 1.1 beta revision
  61.  *
  62.  * Revision 1.1  1995/02/24  14:16:38  brianp
  63.  * Initial revision
  64.  *
  65.  */
  66.  
  67.  
  68. #include <stdlib.h>
  69. #include <string.h>
  70. #include "context.h"
  71. #include "list.h"
  72. #include "macros.h"
  73.  
  74.  
  75. #define MALLOC_STRUCT(T)  (struct T *) malloc( sizeof(struct T) )
  76.  
  77.  
  78.  
  79. static struct gl_attrib_node *new_attrib_node( GLbitfield kind )
  80. {
  81.    struct gl_attrib_node *an;
  82.  
  83.    an = (struct gl_attrib_node *) malloc( sizeof(struct gl_attrib_node) );
  84.    if (an) {
  85.       an->kind = kind;
  86.    }
  87.    return an;
  88. }
  89.  
  90.  
  91.  
  92. void gl_push_attrib( GLbitfield mask )
  93. {
  94.    struct gl_attrib_node *newnode;
  95.    struct gl_attrib_node *head;
  96.  
  97.    if (CC.AttribStackDepth>=MAX_ATTRIB_STACK_DEPTH) {
  98.       gl_error( GL_STACK_OVERFLOW, "glPushAttrib" );
  99.       return;
  100.    }
  101.  
  102.    /* Build linked list of attribute nodes which save all attribute */
  103.    /* groups specified by the mask. */
  104.    head = NULL;
  105.  
  106.    if (mask & GL_ACCUM_BUFFER_BIT) {
  107.       struct gl_accum_attrib *attr;
  108.  
  109.       attr = MALLOC_STRUCT( gl_accum_attrib );
  110.       MEMCPY( attr, &CC.Accum, sizeof(struct gl_accum_attrib) );
  111.       newnode = new_attrib_node( GL_ACCUM_BUFFER_BIT );
  112.       newnode->data = attr;
  113.       newnode->next = head;
  114.       head = newnode;
  115.    }
  116.  
  117.    if (mask & GL_COLOR_BUFFER_BIT) {
  118.       struct gl_colorbuffer_attrib *attr;
  119.       attr = MALLOC_STRUCT( gl_colorbuffer_attrib );
  120.       MEMCPY( attr, &CC.Color, sizeof(struct gl_colorbuffer_attrib) );
  121.       newnode = new_attrib_node( GL_COLOR_BUFFER_BIT );
  122.       newnode->data = attr;
  123.       newnode->next = head;
  124.       head = newnode;
  125.    }
  126.  
  127.    if (mask & GL_CURRENT_BIT) {
  128.       struct gl_current_attrib *attr;
  129.       attr = MALLOC_STRUCT( gl_current_attrib );
  130.       MEMCPY( attr, &CC.Current, sizeof(struct gl_current_attrib) );
  131.       newnode = new_attrib_node( GL_CURRENT_BIT );
  132.       newnode->data = attr;
  133.       newnode->next = head;
  134.       head = newnode;
  135.    }
  136.  
  137.    if (mask & GL_DEPTH_BUFFER_BIT) {
  138.       struct gl_depthbuffer_attrib *attr;
  139.       attr = MALLOC_STRUCT( gl_depthbuffer_attrib );
  140.       MEMCPY( attr, &CC.Depth, sizeof(struct gl_depthbuffer_attrib) );
  141.       newnode = new_attrib_node( GL_DEPTH_BUFFER_BIT );
  142.       newnode->data = attr;
  143.       newnode->next = head;
  144.       head = newnode;
  145.    }
  146.  
  147.    if (mask & GL_ENABLE_BIT) {
  148.       struct gl_enable_attrib *attr;
  149.       GLuint i;
  150.       attr = MALLOC_STRUCT( gl_enable_attrib );
  151.       /* Copy enable flags from all other attributes into the enable struct. */
  152.       attr->AlphaTest = CC.Color.AlphaEnabled;
  153.       attr->AutoNormal = CC.Eval.AutoNormal;
  154.       attr->Blend = CC.Color.BlendEnabled;
  155.       for (i=0;i<MAX_CLIP_PLANES;i++) {
  156.          attr->ClipPlane[i] = CC.Transform.ClipEnabled[i];
  157.       }
  158.       attr->ColorMaterial = CC.Light.ColorMaterialEnabled;
  159.       attr->CullFace = CC.Polygon.CullFlag;
  160.       attr->DepthTest = CC.Depth.Test;
  161.       attr->Dither = CC.Color.DitherFlag;
  162.       attr->Fog = CC.Fog.Enabled;
  163.       for (i=0;i<MAX_LIGHTS;i++) {
  164.          attr->Light[i] = CC.Light.Light[i].Enabled;
  165.       }
  166.       attr->Lighting = CC.Light.Enabled;
  167.       attr->LineSmooth = CC.Line.SmoothFlag;
  168.       attr->LineStipple = CC.Line.StippleFlag;
  169.       attr->LogicOp = CC.Color.LogicOpEnabled;
  170.       attr->Map1Color4 = CC.Eval.Map1Color4;
  171.       attr->Map1Index = CC.Eval.Map1Index;
  172.       attr->Map1Normal = CC.Eval.Map1Normal;
  173.       attr->Map1TextureCoord1 = CC.Eval.Map1TextureCoord1;
  174.       attr->Map1TextureCoord2 = CC.Eval.Map1TextureCoord2;
  175.       attr->Map1TextureCoord3 = CC.Eval.Map1TextureCoord3;
  176.       attr->Map1TextureCoord4 = CC.Eval.Map1TextureCoord4;
  177.       attr->Map1Vertex3 = CC.Eval.Map1Vertex3;
  178.       attr->Map1Vertex4 = CC.Eval.Map1Vertex4;
  179.       attr->Map2Color4 = CC.Eval.Map2Color4;
  180.       attr->Map2Index = CC.Eval.Map2Index;
  181.       attr->Map2Normal = CC.Eval.Map2Normal;
  182.       attr->Map2TextureCoord1 = CC.Eval.Map2TextureCoord1;
  183.       attr->Map2TextureCoord2 = CC.Eval.Map2TextureCoord2;
  184.       attr->Map2TextureCoord3 = CC.Eval.Map2TextureCoord3;
  185.       attr->Map2TextureCoord4 = CC.Eval.Map2TextureCoord4;
  186.       attr->Map2Vertex3 = CC.Eval.Map2Vertex3;
  187.       attr->Map2Vertex4 = CC.Eval.Map2Vertex4;
  188.       attr->Normalize = CC.Transform.Normalize;
  189.       attr->PointSmooth = CC.Point.SmoothFlag;
  190.       attr->PolygonOffset = CC.Polygon.OffsetEnabled;
  191.       attr->PolygonSmooth = CC.Polygon.SmoothFlag;
  192.       attr->PolygonStipple = CC.Polygon.StippleFlag;
  193.       attr->Scissor = CC.Scissor.Enabled;
  194.       attr->Stencil = CC.Stencil.Enabled;
  195.       attr->Texture = CC.Texture.Enabled;
  196.       attr->TexGen = CC.Texture.TexGenEnabled;
  197.       newnode = new_attrib_node( GL_ENABLE_BIT );
  198.       newnode->data = attr;
  199.       newnode->next = head;
  200.       head = newnode;
  201.    }
  202.  
  203.    if (mask & GL_EVAL_BIT) {
  204.       struct gl_eval_attrib *attr;
  205.       attr = MALLOC_STRUCT( gl_eval_attrib );
  206.       MEMCPY( attr, &CC.Eval, sizeof(struct gl_eval_attrib) );
  207.       newnode = new_attrib_node( GL_EVAL_BIT );
  208.       newnode->data = attr;
  209.       newnode->next = head;
  210.       head = newnode;
  211.    }
  212.  
  213.    if (mask & GL_FOG_BIT) {
  214.       struct gl_fog_attrib *attr;
  215.       attr = MALLOC_STRUCT( gl_fog_attrib );
  216.       MEMCPY( attr, &CC.Fog, sizeof(struct gl_fog_attrib) );
  217.       newnode = new_attrib_node( GL_FOG_BIT );
  218.       newnode->data = attr;
  219.       newnode->next = head;
  220.       head = newnode;
  221.    }
  222.  
  223.    if (mask & GL_HINT_BIT) {
  224.       struct gl_hint_attrib *attr;
  225.       attr = MALLOC_STRUCT( gl_hint_attrib );
  226.       MEMCPY( attr, &CC.Hint, sizeof(struct gl_hint_attrib) );
  227.       newnode = new_attrib_node( GL_HINT_BIT );
  228.       newnode->data = attr;
  229.       newnode->next = head;
  230.       head = newnode;
  231.    }
  232.  
  233.    if (mask & GL_LIGHTING_BIT) {
  234.       struct gl_light_attrib *attr;
  235.       attr = MALLOC_STRUCT( gl_light_attrib );
  236.       MEMCPY( attr, &CC.Light, sizeof(struct gl_light_attrib) );
  237.       newnode = new_attrib_node( GL_LIGHTING_BIT );
  238.       newnode->data = attr;
  239.       newnode->next = head;
  240.       head = newnode;
  241.    }
  242.  
  243.    if (mask & GL_LINE_BIT) {
  244.       struct gl_line_attrib *attr;
  245.       attr = MALLOC_STRUCT( gl_line_attrib );
  246.       MEMCPY( attr, &CC.Line, sizeof(struct gl_line_attrib) );
  247.       newnode = new_attrib_node( GL_LINE_BIT );
  248.       newnode->data = attr;
  249.       newnode->next = head;
  250.       head = newnode;
  251.    }
  252.  
  253.    if (mask & GL_LIST_BIT) {
  254.       struct gl_list_attrib *attr;
  255.       attr = MALLOC_STRUCT( gl_list_attrib );
  256.       MEMCPY( attr, &CC.List, sizeof(struct gl_list_attrib) );
  257.       newnode = new_attrib_node( GL_LIST_BIT );
  258.       newnode->data = attr;
  259.       newnode->next = head;
  260.       head = newnode;
  261.    }
  262.  
  263.    if (mask & GL_PIXEL_MODE_BIT) {
  264.       struct gl_pixel_attrib *attr;
  265.       attr = MALLOC_STRUCT( gl_pixel_attrib );
  266.       MEMCPY( attr, &CC.Pixel, sizeof(struct gl_pixel_attrib) );
  267.       newnode = new_attrib_node( GL_PIXEL_MODE_BIT );
  268.       newnode->data = attr;
  269.       newnode->next = head;
  270.       head = newnode;
  271.    }
  272.  
  273.    if (mask & GL_POINT_BIT) {
  274.       struct gl_point_attrib *attr;
  275.       attr = MALLOC_STRUCT( gl_point_attrib );
  276.       MEMCPY( attr, &CC.Point, sizeof(struct gl_point_attrib) );
  277.       newnode = new_attrib_node( GL_POINT_BIT );
  278.       newnode->data = attr;
  279.       newnode->next = head;
  280.       head = newnode;
  281.    }
  282.  
  283.    if (mask & GL_POLYGON_BIT) {
  284.       struct gl_polygon_attrib *attr;
  285.       attr = MALLOC_STRUCT( gl_polygon_attrib );
  286.       MEMCPY( attr, &CC.Polygon, sizeof(struct gl_polygon_attrib) );
  287.       newnode = new_attrib_node( GL_POLYGON_BIT );
  288.       newnode->data = attr;
  289.       newnode->next = head;
  290.       head = newnode;
  291.    }
  292.  
  293.    if (mask & GL_POLYGON_STIPPLE_BIT) {
  294.       GLuint *stipple;
  295.       stipple = (GLuint *) malloc( 32*sizeof(GLuint) );
  296.       MEMCPY( stipple, CC.PolygonStipple, 32*sizeof(GLuint) );
  297.       newnode = new_attrib_node( GL_POLYGON_STIPPLE_BIT );
  298.       newnode->data = stipple;
  299.       newnode->next = head;
  300.       head = newnode;
  301.    }
  302.  
  303.    if (mask & GL_SCISSOR_BIT) {
  304.       struct gl_scissor_attrib *attr;
  305.       attr = MALLOC_STRUCT( gl_scissor_attrib );
  306.       MEMCPY( attr, &CC.Scissor, sizeof(struct gl_scissor_attrib) );
  307.       newnode = new_attrib_node( GL_SCISSOR_BIT );
  308.       newnode->data = attr;
  309.       newnode->next = head;
  310.       head = newnode;
  311.    }
  312.  
  313.    if (mask & GL_STENCIL_BUFFER_BIT) {
  314.       struct gl_stencil_attrib *attr;
  315.       attr = MALLOC_STRUCT( gl_stencil_attrib );
  316.       MEMCPY( attr, &CC.Stencil, sizeof(struct gl_stencil_attrib) );
  317.       newnode = new_attrib_node( GL_STENCIL_BUFFER_BIT );
  318.       newnode->data = attr;
  319.       newnode->next = head;
  320.       head = newnode;
  321.    }
  322.  
  323.    if (mask & GL_TEXTURE_BIT) {
  324.       struct gl_texture_attrib *attr;
  325.       attr = MALLOC_STRUCT( gl_texture_attrib );
  326.       MEMCPY( attr, &CC.Texture, sizeof(struct gl_texture_attrib) );
  327.       newnode = new_attrib_node( GL_TEXTURE_BIT );
  328.       newnode->data = attr;
  329.       newnode->next = head;
  330.       head = newnode;
  331.    }
  332.  
  333.    if (mask & GL_TRANSFORM_BIT) {
  334.       struct gl_transform_attrib *attr;
  335.       attr = MALLOC_STRUCT( gl_transform_attrib );
  336.       MEMCPY( attr, &CC.Transform, sizeof(struct gl_transform_attrib) );
  337.       newnode = new_attrib_node( GL_TRANSFORM_BIT );
  338.       newnode->data = attr;
  339.       newnode->next = head;
  340.       head = newnode;
  341.    }
  342.  
  343.    if (mask & GL_VIEWPORT_BIT) {
  344.       struct gl_viewport_attrib *attr;
  345.       attr = MALLOC_STRUCT( gl_viewport_attrib );
  346.       MEMCPY( attr, &CC.Viewport, sizeof(struct gl_viewport_attrib) );
  347.       newnode = new_attrib_node( GL_VIEWPORT_BIT );
  348.       newnode->data = attr;
  349.       newnode->next = head;
  350.       head = newnode;
  351.    }
  352.  
  353.    /* etc... */
  354.  
  355.    CC.AttribStack[CC.AttribStackDepth] = head;
  356.    CC.AttribStackDepth++;
  357. }
  358.  
  359.  
  360.  
  361. void gl_pop_attrib( void )
  362. {
  363.    struct gl_attrib_node *attr, *next;
  364.    struct gl_enable_attrib *enable;
  365.    GLuint i;
  366.  
  367.    if (CC.AttribStackDepth==0) {
  368.       gl_error( GL_STACK_UNDERFLOW, "glPopAttrib" );
  369.       return;
  370.    }
  371.  
  372.    CC.AttribStackDepth--;
  373.    attr = CC.AttribStack[CC.AttribStackDepth];
  374.  
  375.    while (attr) {
  376.       switch (attr->kind) {
  377.          case GL_ACCUM_BUFFER_BIT:
  378.             MEMCPY( &CC.Accum, attr->data, sizeof(struct gl_accum_attrib) );
  379.             break;
  380.          case GL_COLOR_BUFFER_BIT:
  381.             MEMCPY( &CC.Color, attr->data,
  382.             sizeof(struct gl_colorbuffer_attrib) );
  383.             break;
  384.          case GL_CURRENT_BIT:
  385.             MEMCPY( &CC.Current, attr->data,
  386.             sizeof(struct gl_current_attrib) );
  387.             break;
  388.          case GL_DEPTH_BUFFER_BIT:
  389.             MEMCPY( &CC.Depth, attr->data,
  390.             sizeof(struct gl_depthbuffer_attrib) );
  391.             break;
  392.          case GL_ENABLE_BIT:
  393.             enable = (struct gl_enable_attrib *) attr->data;
  394.             CC.Color.AlphaEnabled = enable->AlphaTest;
  395.             CC.Transform.Normalize = enable->AutoNormal;
  396.             CC.Color.BlendEnabled = enable->Blend;
  397.         for (i=0;i<MAX_CLIP_PLANES;i++) {
  398.                CC.Transform.ClipEnabled[i] = enable->ClipPlane[i];
  399.         }
  400.         CC.Light.ColorMaterialEnabled = enable->ColorMaterial;
  401.         CC.Polygon.CullFlag = enable->CullFace;
  402.         CC.Depth.Test = enable->DepthTest;
  403.         CC.Color.DitherFlag = enable->Dither;
  404.         CC.Fog.Enabled = enable->Fog;
  405.             CC.Light.LastEnabled = -1;
  406.         for (i=0;i<MAX_LIGHTS;i++) {
  407.            CC.Light.Light[i].Enabled = enable->Light[i];
  408.                if (enable->Light[i]) {
  409.                   CC.Light.LastEnabled = i;
  410.                }
  411.         }
  412.         CC.Light.Enabled = enable->Lighting;
  413.         CC.Line.SmoothFlag = enable->LineSmooth;
  414.         CC.Line.StippleFlag = enable->LineStipple;
  415.         CC.Color.LogicOpEnabled = enable->LogicOp;
  416.         CC.Eval.Map1Color4 = enable->Map1Color4;
  417.         CC.Eval.Map1Index = enable->Map1Index;
  418.         CC.Eval.Map1Normal = enable->Map1Normal;
  419.         CC.Eval.Map1TextureCoord1 = enable->Map1TextureCoord1;
  420.         CC.Eval.Map1TextureCoord2 = enable->Map1TextureCoord2;
  421.         CC.Eval.Map1TextureCoord3 = enable->Map1TextureCoord3;
  422.         CC.Eval.Map1TextureCoord4 = enable->Map1TextureCoord4;
  423.         CC.Eval.Map1Vertex3 = enable->Map1Vertex3;
  424.         CC.Eval.Map1Vertex4 = enable->Map1Vertex4;
  425.         CC.Eval.Map2Color4 = enable->Map2Color4;
  426.         CC.Eval.Map2Index = enable->Map2Index;
  427.         CC.Eval.Map2Normal = enable->Map2Normal;
  428.         CC.Eval.Map2TextureCoord1 = enable->Map2TextureCoord1;
  429.         CC.Eval.Map2TextureCoord2 = enable->Map2TextureCoord2;
  430.         CC.Eval.Map2TextureCoord3 = enable->Map2TextureCoord3;
  431.         CC.Eval.Map2TextureCoord4 = enable->Map2TextureCoord4;
  432.         CC.Eval.Map2Vertex3 = enable->Map2Vertex3;
  433.         CC.Eval.Map2Vertex4 = enable->Map2Vertex4;
  434.         CC.Transform.Normalize = enable->Normalize;
  435.         CC.Point.SmoothFlag = enable->PointSmooth;
  436.         CC.Polygon.OffsetEnabled = enable->PolygonOffset;
  437.         CC.Polygon.SmoothFlag = enable->PolygonSmooth;
  438.         CC.Polygon.StippleFlag = enable->PolygonStipple;
  439.         CC.Scissor.Enabled = enable->Scissor;
  440.         CC.Stencil.Enabled = enable->Stencil;
  441.         CC.Texture.Enabled = enable->Texture;
  442.         CC.Texture.TexGenEnabled = enable->TexGen;
  443.             break;
  444.          case GL_EVAL_BIT:
  445.             MEMCPY( &CC.Eval, attr->data, sizeof(struct gl_eval_attrib) );
  446.             break;
  447.          case GL_FOG_BIT:
  448.             MEMCPY( &CC.Fog, attr->data, sizeof(struct gl_fog_attrib) );
  449.             break;
  450.          case GL_HINT_BIT:
  451.             MEMCPY( &CC.Hint, attr->data, sizeof(struct gl_hint_attrib) );
  452.             break;
  453.          case GL_LIGHTING_BIT:
  454.             MEMCPY( &CC.Light, attr->data, sizeof(struct gl_light_attrib) );
  455.             break;
  456.          case GL_LINE_BIT:
  457.             MEMCPY( &CC.Line, attr->data, sizeof(struct gl_line_attrib) );
  458.             break;
  459.          case GL_LIST_BIT:
  460.             MEMCPY( &CC.List, attr->data, sizeof(struct gl_list_attrib) );
  461.             break;
  462.          case GL_PIXEL_MODE_BIT:
  463.             MEMCPY( &CC.Pixel, attr->data, sizeof(struct gl_pixel_attrib) );
  464.             break;
  465.          case GL_POINT_BIT:
  466.             MEMCPY( &CC.Point, attr->data, sizeof(struct gl_point_attrib) );
  467.             break;
  468.          case GL_POLYGON_BIT:
  469.             MEMCPY( &CC.Polygon, attr->data,
  470.             sizeof(struct gl_polygon_attrib) );
  471.             break;
  472.      case GL_POLYGON_STIPPLE_BIT:
  473.         MEMCPY( CC.PolygonStipple, attr->data, 32*sizeof(GLuint) );
  474.         break;
  475.          case GL_SCISSOR_BIT:
  476.             MEMCPY( &CC.Scissor, attr->data,
  477.             sizeof(struct gl_scissor_attrib) );
  478.             break;
  479.          case GL_STENCIL_BUFFER_BIT:
  480.             MEMCPY( &CC.Stencil, attr->data,
  481.             sizeof(struct gl_stencil_attrib) );
  482.             break;
  483.          case GL_TRANSFORM_BIT:
  484.             MEMCPY( &CC.Transform, attr->data,
  485.             sizeof(struct gl_transform_attrib) );
  486.             break;
  487.          case GL_TEXTURE_BIT:
  488.             MEMCPY( &CC.Texture, attr->data,
  489.             sizeof(struct gl_texture_attrib) );
  490.             break;
  491.          case GL_VIEWPORT_BIT:
  492.             MEMCPY( &CC.Viewport, attr->data,
  493.             sizeof(struct gl_viewport_attrib) );
  494.         /* Check if span clipping is needed (see gl_viewport) */
  495.         if (CC.Viewport.X<0 || CC.Viewport.Y<0
  496.         || CC.Viewport.X+CC.Viewport.Width>CC.BufferWidth
  497.         || CC.Viewport.X+CC.Viewport.Height>CC.BufferHeight) {
  498.            CC.ClipSpans = GL_TRUE;
  499.         }
  500.         else {
  501.            CC.ClipSpans = GL_FALSE;
  502.         }
  503.  
  504.             break;
  505.          default:
  506.             /* ERROR! */
  507.             break;
  508.       }
  509.  
  510.       next = attr->next;
  511.       free( (void *) attr->data );
  512.       free( (void *) attr );
  513.       attr = next;
  514.    }
  515.  
  516.    CC.NewState = GL_TRUE;
  517. }
  518.  
  519.  
  520.  
  521. void glPushAttrib( GLbitfield mask )
  522. {
  523.    if (CC.CompileFlag) {
  524.       gl_save_pushattrib( mask );
  525.    }
  526.    if (CC.ExecuteFlag) {
  527.       gl_push_attrib( mask );
  528.    }
  529. }
  530.  
  531.  
  532.  
  533. void glPopAttrib( void )
  534. {
  535.    if (CC.CompileFlag) {
  536.       gl_save_popattrib();
  537.    }
  538.    if (CC.ExecuteFlag) {
  539.       gl_pop_attrib();
  540.    }
  541. }
  542.